import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
  String _accountName;

  @override
  void initState() {
    _accountName = "Admin";
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Admin"),
        centerTitle: false,
        actions: [
          IconButton(icon: Icon(Icons.exit_to_app), onPressed: () {}),
        ],
      ),
      drawer: BuildDrawer(accountName: _accountName),
    );
  }
}

class BuildDrawer extends StatelessWidget {
  const BuildDrawer({
    Key key,
    @required String accountName,
  })  : _accountName = accountName,
        super(key: key);

  final String _accountName;

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        children: [
          UserAccountsDrawerHeader(
            accountName: Text(_accountName),
            accountEmail: null,
            onDetailsPressed: () {},
          ),
          ListTile(
            title: Text("人员管理"),
            leading: Icon(Icons.people),
            onTap: () {},
          ),
          ListTile(
            title: Text("设置"),
            leading: Icon(Icons.settings),
            onTap: () {},
          ),
          ExpansionPanelList(
            children: [
              ExpansionPanel(
                headerBuilder: (_, bool expended) {
                  return Text("AAA");
                },
                body: ListTile(
                  title: Text("AAA"),
                  subtitle:
                      Text('To delete this panel, tap the trash can icon'),
                  trailing: Icon(Icons.delete),
                  onTap: () {},
                ),
                isExpanded: true,
              ),
            ],
          ),
        ],
      ),
    );
  }
}
